#ifndef __REDCELL_COMMON_HPP__
#define __REDCELL_COMMON_HPP__

#include <string>
#include <sstream>
#include <stdexcept>


#define REDCELL_WITHBOOST 0
#define REDCELL_STRINGKEYS 1

namespace redcell {
  typedef long long Integer;
  typedef double Real;
  typedef std::string String;

  typedef std::size_t IntKey;

#if REDCELL_STRINGKEYS
  typedef std::string StrKey;
#endif
  //  typedef std::size_t Key;
  //#endif


  enum {
    FALSE = 0,
    TRUE = 1,
  };

  enum {
    F_PADDING = 0x0,
    F_TRUE = 0x1,
    F_FALSE = 0x2,
    F_POS = 0x3,
    F_NEG = 0x4,
    F_FLOAT = 0x5,
    F_DOUBLE = 0x6,
    F_STR = 0x7,
    F_NIL = 0x8,
    F_SUB = 0x9,
    F_EMPTYSUB = 0xa,
    F_STRKEY = 0x0d,
    F_KEYSKIP = 0x0e,
    F_END = 0xf,
  };


  enum {
    NIL = 0x00,
    INTEGER = 0x01,
    REAL = 0x02,
    STRING = 0x08,
    TABLE = 0x09,

#if REDCELL_STRINGKEYS
    INTKEY = 0x11,
    STRKEY = 0x18,
#endif
  };


  struct Error: public std::runtime_error {
    Error(const String &what = "error"): std::runtime_error("redcell: " + what) {}
  };

  struct MarshalError: public Error {
    MarshalError(const String &what = "error"): Error("Marshal: " + what) {}
  };

  /*
  struct StreamError: public Error {
    StreamError(const String &what = "error"): Error("Stream: " + what) {}
  };
  */

}


#endif
